from pydantic import BaseModel
from typing import Optional, Any
import datetime

from .user import User
from app.models.generation_job import JobStatus

# Shared properties
class GenerationJobBase(BaseModel):
    prompt: str
    params: Optional[dict[str, Any]] = None

# Properties to receive via API on creation
class GenerationJobCreate(GenerationJobBase):
    pass

# Properties to receive via API on update
class GenerationJobUpdate(BaseModel):
    status: Optional[JobStatus] = None
    result_url: Optional[str] = None
    is_public: Optional[bool] = None
    title: Optional[str] = None
    description: Optional[str] = None

class GenerationJobInDBBase(GenerationJobBase):
    id: int
    user_id: int
    status: JobStatus
    result_url: Optional[str] = None
    created_at: datetime.datetime
    is_public: bool
    title: Optional[str] = None
    description: Optional[str] = None
    likes_count: int

    class Config:
        from_attributes = True

# Additional properties to return via API
class GenerationJob(GenerationJobInDBBase):
    owner: User

# Additional properties stored in DB
class GenerationJobInDB(GenerationJobInDBBase):
    pass
